The present invention relates to constructing pathnames for locating files.
One common way to organize files is with a directory structure that allows files or directories to reside within other directories. When a directory resides within another directory, the residing directory is referred to as a xe2x80x9csubdirectoryxe2x80x9d. A file ultimately resides in a parent directory. The file""s parent directory may, in turn, have a parent directory, and so on, thus creating a hierarchy of directories. To access a particular file, each of the parent directories in a chain from a starting or xe2x80x9croot,xe2x80x9d directory are named in a string, along with the file""s name. The resulting string is referred to as a xe2x80x9cpathnamexe2x80x9d.
An absolute pathname uniquely identifies any file in a specific file system without requiring further information.
Consider as an example a file xe2x80x9cfileXxe2x80x9d with an absolute pathname xe2x80x9cHardDrive: directoryA directoryB directoryC fileXxe2x80x9d. The directory xe2x80x9cdirectoryAxe2x80x9d is the root directory, which is always given as a starting directory in an absolute pathname.
Another form of pathname is a relative pathname, which identifies a file by using a relative path and a reference point such as a xe2x80x9ccurrentxe2x80x9d or starting directory (other than the root directory). Using the same example as above, and assuming the current directory is xe2x80x9cdirectory Cxe2x80x9d, a relative path to be used to access xe2x80x9cfileXxe2x80x9d is xe2x80x9c directoryC fileXxe2x80x9d.
It is quite common for documents having imported files to specify links to those files. In the case of a document which references another file such as an image file, the referencing document will include either an absolute or a relative pathname for accessing the image file. If a user moves the entire directory hierarchy associated with the document to a new location, the linked file""s absolute pathname (if specified) continues to point to the old location. When the document is opened, the associated file will be missing, i.e., not at the specified location. Consequently, user input is required to locate the missing file.
It would be relatively straightforward to locate the linked file if its location were specified by a relative pathname, but many applications do not maintain relative pathnames as links. Some applications, such as applications which handle legacy data, do not support relative pathnames. These applications record the absolute pathname of the referenced file, but not that of the referencing document.
Even when relative pathnames are supported, there are various drawbacks associated with their use. For example, when the directory structure is changed instead of merely moved or the document and its associated linked file are not moved together, a relative pathname may not provide sufficient information to reconstruct the link.
One prior link repairing technique employed by applications which use absolute pathnames for linking tries to find a missing linked file in the referencing document""s directory and goes no further. That is, any further attempts to locate a missing linked file require user involvement.
Another prior approach to repairing absolute pathname links requires user involvement and is site-specific, i.e., it can repair links for files which have been moved to a different location at the same site.
In one aspect of the invention, a linked file is located by retrieving a reference to a linked file linked to a document. The reference specifies an original absolute pathname.
The absolute pathname is parsed into a plurality of relative pathnames and a first one of the relative pathnames is appended to a current directory specification for the document to produce a new absolute pathname. Subsequent ones of the plurality of relative pathnames are appended to the current directory specification until the new absolute pathname points to the linked file.
Embodiments of the invention may include one or more of the following features.
The linked file may reside in the same directory structure as the document to which the linked file is linked.
The reference may be stored in the document to which the linked file is linked and the original absolute pathname may be replaced with the new absolute pathname.
The linked file locating mechanism of the invention offers several advantages. It allows an application to locate automatically (i.e., without user involvement) a file referenced by a document when the directory structure in which both the file and the document reside has been moved to a different location. The mechanism is therefore compatible with applications that cannot or do not support relative pathnames as links.